package com.yit.data.variance

class Person {

  private var name: String = "bobo"
  protected var age: Int = 18
  private[test] var sex: String = "男"

  def say(): Unit = println(name)

}

object Person {

  def main(args: Array[String]): Unit = {

    val person = new Person

    person.say()
    // 伴生对象可以访问私有属性
    println(person.name)

    println(person.age)
  }
}

class Teacher extends Person {

  def test(): Unit = {
    this.age // protected修饰可以被子类所访问
    this.sex // private[包名]增加包访问权限，包名下的其他类也可以使用
  }
}
